<template>
  <div class="history-card" @click="$emit('click')">
    <div class="history-card__header">
      <span>{{ data.titleName }}</span>
      <van-icon name="arrow" />
    </div>
    <div class="history-card__body">
      <info-item label="测评得分" :value="score" />
      <info-item label="测评时间" :value="data.createTime" />
    </div>
  </div>
</template>

<script>
import InfoItem from '@/components/InfoItem.vue'
import { Icon } from 'vant'

export default {
  components: {
    InfoItem,
    [Icon.name]: Icon
  },
  props: {
    data: {
      type: Object,
      required: true
    }
  },
  computed: {
    score() {
      if (!this.data.score && this.data.score !== 0) {
        return ''
      }
      return this.data.score + '分'
    }
  }
}
</script>

<style lang="less">
.history-card {
  background-color: #ffffff;
  box-shadow: inset 0 -2px 0 0 #f5f5f5;

  &__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 36px;
    font-family: @font-medium;
    font-weight: 500;
    color: #222222;
    height: 128px;
    display: flex;
    align-items: center;
    padding: 0 40px;
    position: relative;
    box-shadow: inset 0 -2px 0 0 #f5f5f5;

    &::before {
      content: '';
      position: absolute;
      top: 50%;
      left: 0;
      transform: translateY(-50%);
      height: 32px;
      width: 8px;
      border-radius: 0 8px 8px 0;
      background-color: @primary;
    }
  }

  &__body {
    padding: 30px 40px;
  }

  .info-item + .info-item {
    margin-top: 30px;
  }

  .van-icon {
    color: #cccccc;
    font-weight: bold;
  }
}
</style>
